class Solution {
public:
    vector<vector<int>> vv;
    bool vis[6];
    vector<int> tmp;
    vector<vector<int>> permute(vector<int>& nums) {
        dfs(nums);
        return vv;
    }
    void dfs(vector<int>& nums)
    {
        if (nums.size() == tmp.size())
        {
            vv.push_back(tmp);
            return;
        }
        for (int i = 0;i < nums.size();i++)
        {
            if (!vis[i])
            {
                tmp.push_back(nums[i]);
                vis[i] = 1;
            }
            else
            {
                continue;
            }
            dfs(nums);
            tmp.pop_back();
            vis[i] = 0;
        }
    }
};